home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 582 < prev    next >
Internet Message Format  |  1996-08-06  |  3KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.std.c
  4. Subject: Re: sizeof(char) ~= sizeof(float)
  5. Date: Sun, 17 Mar 96 00:59:21 GMT
  6. Organization: none
  7. Message-ID: <827024361snz@genesis.demon.co.uk>
  8. References: <WALD.96Feb24131532@woodpecker.lcs.mit.edu> <4gr3d1$dca@usenet.pa.dec.com> <TANMOY.96Feb27114201@qcd.lanl.gov>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <TANMOY.96Feb27114201@qcd.lanl.gov>
  15.            tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
  16.  
  17. >In article <DnFr78.1wo@ukpsshp1.serigate.philips.nl>
  18. >baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes:
  19. >
  20. >SB: Tanmoy Bhattacharya (tanmoy@qcd.lanl.gov) wrote:
  21. >SB: : In article <4gr3d1$dca@usenet.pa.dec.com>
  22. >SB: : diamond@tbj.dec.com (Norman Diamond) writes:
  23. >SB: <snip - copying data by using chars of different sorts vs memcpy >
  24. >SB: : This was a free-standing implementation, and memcpy may be absent. (In
  25. >SB: : a hosted implementation, as all read/write is done as if through
  26. >SB: : getc/putc which handles unsigned char values, and binary files written
  27. >SB: : out must be read back unchanged, the situation is impossible).
  28. >SB: 
  29. >SB: That read/write is done by getc/putc does not imply very much about copying
  30. >SB: chars. I don't see any requirement that fwrite/fread use one putc/getc per
  31. >SB: byte(ie char) of memory. Fwrite could use one per bit writing the
  32. >values 'Y' or 
  33. >SB: 'N' if it wanted so long as fread will read it back again. My
  34. >understanding 
  35. >SB: is that the use of getc/putc means you can write a file with
  36. >fwrite, copy it 
  37. >SB: with getc/putc and read the copy with fread to get what you started with.
  38. >
  39. >I understood it to mean that I could take the same (void*) pointer to
  40. >the data, and call putc repeatedly on the successive bytes of the
  41. >data, and the resulting file is identical to doing an fwrite. I think
  42. >the standard should clarify its meaning.
  43.  
  44. OK, I'm a little late in getting round to this! :-)
  45.  
  46. This is a property that fread/fwrite really must have if they are to be
  47. of much use. Without it you can't use them for random access reading/writing
  48. of record because you don't know how large those records are going to
  49. end up being in the file, even using a binary stream.
  50.  
  51. This would also bring into question whether:
  52.  
  53. fwrite(str, 1, strlen(str), fp)
  54.  
  55. has the same effect (ignoring the return values) as:
  56.  
  57. fputs(str, fp)
  58.  
  59. for valid arguments.
  60.  
  61. -- 
  62. -----------------------------------------
  63. Lawrence Kirby | fred@genesis.demon.co.uk
  64. Wilts, England | 70734.126@compuserve.com
  65. -----------------------------------------
  66.